var app = getApp()
export const rightJudge = (teamId) => {
  // 在用户信息中查找权限
  let thisUserInfo = app.globalData.userInfo
  let result = ''
  if(thisUserInfo){
    // 在manageTeamList中查找
    if(thisUserInfo.manageTeamList && thisUserInfo.manageTeamList.length!=0){
      thisUserInfo.manageTeamList.map(v=>{
        if(v.teamId == teamId){
          result = 2
        }
      })
      // 找到了就返回
      if(result){
        return result
      }
    }
    // 在joinTeamList中查找
    if(thisUserInfo.joinTeamList && thisUserInfo.joinTeamList.length!=0){
      thisUserInfo.joinTeamList.map(v=>{
        if(v.teamId == teamId){
          result = v.power
        }
      })
      if(result){
        return result
      }else{
        return '未能查找到对应权限'
      }
    }else if(thisUserInfo.role == '领导'){
      return '用户是领导'
    }else{
      return '用户未加入任何团队'
    }
  }else{
    return '用户未登录'
  }
}